import {
	useAppStore
} from '@/store/store.js'

/**
 * @param {Object} product
 */
export function useAddCart(product) {
	const store = useAppStore()
	const finder = store.shopping.find((item) => item.serial === product.serial);
	if (finder) {
		finder.number += 1;
		finder.checked = true;
	} else {
		// 加入购物默认+1选中 number 数量 checked 默认选中
		product.number = 1;
		product.checked = true;
		store.unshift('shopping', product);
	}
}